<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1 user-scalable=0">
<link rel="stylesheet" href="<%=basePath%>assets/css/public.css">
<link rel="stylesheet"
	href="<%=basePath%>assets/css/idangerous.swiper.css">

<title>搜索</title>
<script src="<%=basePath%>assets/js/jquery-1.8.3.min.js"></script>
<script src="<%=basePath%>assets/js/fontSize.js"></script>
<link href="<%=basePath%>/assets/layer/mobile/need/layer.css"
	rel="stylesheet" type="text/css">
<script src="<%=basePath%>/assets/layer/mobile/layer.js"></script>
<link rel="stylesheet" href="<%=basePath%>assets/css/page.css">
<link rel="stylesheet"
	href="<%=basePath%>assets/font-awesome-4.7.0/css/font-awesome.min.css">
<style>
body{
	padding-top: 0.8rem;
}
.header {
	background: #f8f8f8;
}

.search {
	width: 70%;
	border-bottom: 1px solid #f1f1f1;
	border-radius: 0.05rem;
	height: 0.6rem;
	line-height: 0.6rem;
	background: #FFFFFF url(<%=basePath%>assets/imgMenu/ss.png) no-repeat 0.1rem 0.1rem;
	background-size: 0.4rem 0.4rem;
	padding-left: 0.6rem;
	font-size: 0.24rem;
	position: relative;
}

#btn {
	font-size: 0.24rem;
	margin-left: 0.2rem;
	position: absolute;
	top: 0;
	right: 0.2rem;
	line-height:0.8rem;
	color: #333;
}

.zuijinsousuo {
	background: #ffffff
}

.zuijinsousuo .zuijinsousuo{
	font-weight: bold;
	font-size: 0.26rem;
}

.zuijinClass {
	background: #f1f1f1;
	line-height: 0.4rem;
}

.zuijinsousuo, .resoubang {
	width: 94%;
	padding: 0 3%;
}

.zuijinsousuo ul li, .resoubang ul li {
	float: left;
	padding: 0.06rem 0.1rem 0 0.1rem;
	margin: 0 0.1rem 0.1rem 0.1rem;
	border-radius: 50px;
}

.zuijinsousuo ul li a, .resoubang ul li a {
	font-size: 0.22rem;
	height: 0.4rem;
	line-height: 0.4rem
}

.resoubang ul li {
	background: #f1f1f1;
	line-height: 0.4rem;
}

.resoubang h3, .zuijinsousuo h3 {
	margin: 0.2rem 0;
	height: 0.6rem;
	line-height: 0.6rem;
	font-weight:bold;
	font-size: 0.26rem;
}

.resoubang h3 {
	border-bottom: 1px solid #f1f1f1;
}

.zuijinsousuo_shanchu {
	font-weight: normal;
	font-size: 0.22rem;
}
</style>
</head>
<body>
	<div class="header clearFirx">
		<a class="returnInfo" id="fanhui" href="#"><i class="fa fa-angle-left"></i></a>
		<input id="content" type="search" placeholder="萌校商品" class="search" autofocus="autofocus">
		<span id="btn">搜索</span>
	</div>
	<c:if test="${not empty recentlySearchList}">
		<div class="zuijinsousuo clearFirx">
			<h3>
				最近搜索
				<span class="float_r zuijinsousuo_shanchu">清空</span>
			</h3>
			<ul class="zuijinsousuo_neirong">
				<c:forEach var="recentlySearchList" items="${recentlySearchList}">
					<li class="zuijinClass"
						hotSearchId="${recentlySearchList.hotSearchId}"><a
						href="<%=basePath%>app/indexSearch?content=${recentlySearchList.hotSearchResult}">${recentlySearchList.hotSearchResult}</a></li>
				</c:forEach>
			</ul>
		</div>
	</c:if>
	<div class="resoubang clearFirx">
		<h3>热搜榜</h3>
		<ul>
			<c:forEach var="hotSearchList" items="${hotSearchList}">
				<li><a
					href="<%=basePath%>app/indexSearch?content=${hotSearchList.hotSearchResult}">${hotSearchList.hotSearchResult}</a></li>
			</c:forEach>
		</ul>

	</div>
</body>
<script type="text/javascript">
	$(function(){
		//清空最近搜索
	    $('.zuijinsousuo_shanchu').click(function () {
            var hotSearchId = "";
			$('.zuijinsousuo_neirong li').each(function () {
				hotSearchId += $(this).attr("hotSearchId")+","
			});
			//后台删除
			$.ajax({
		    	url: "<%=basePath%>app/delRecentlySearchOneResult",
		        timeout: 300000,
		        dataType: "json",
		        type: "post",
		        data: {
		        	"hotSearchId":hotSearchId
		        },
		        success : function(data) {
		        	if(data.num==1){
		        		layer.open({
		      			    content: '您删除了最近的搜索记录'
		      			    ,skin: 'msg'
		      			    ,time: 2 //2秒后自动关闭
		      			  });
		        		$('.zuijinsousuo').children().remove();
		        	}else{
		        		layer.open({
		      			    content: '删除出现了问题，请稍等亲~'
		      			    ,skin: 'msg'
		      			    ,time: 2 //2秒后自动关闭
		      			  });
		        	}
		        }
		    });
			
        });
		$("#btn").click(function(){
			if($("#content").val() == "" || $("#content").val() == null){
				layer.open({
      			    content: '请输入搜索内容'
      			    ,skin: 'msg'
      			    ,time: 2 //2秒后自动关闭
   			  	});
				return false;
			}
			window.location.href="<%=basePath%>app/indexSearch?content="+$("#content").val();
		});
	    //点击返回
	    $("#fanhui").click(function () {
	    	window.location.href="<%=basePath%>app/appIndex";
		});
	})
</script>
</html>